﻿using System;
using System.Windows.Forms;
using DevExpress.XtraEditors;
using Awesomium.Windows.Forms;
using System.IO;

namespace NHTClient.Objects
{
    public partial class NHTPayment : XtraForm
    {
        private NHTMain mainForm;
        private String ProfileIdentifier { get; set; }
        private String RandomString
        {
            get
            {
                var chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
                var stringChars = new char[8];
                var random = new Random();

                for (int i = 0; i < stringChars.Length; i++)
                {
                    stringChars[i] = chars[random.Next(chars.Length)];
                }

                var finalString = new String(stringChars);

                return finalString;
            }
        }

        public NHTPayment(NHTMain form)
        {
            InitializeComponent();

            mainForm = form;
            ProfileIdentifier = RandomString;

            var browser = new WebDocument("http://5.maxgate.vn/nap-tien")
            {
                Dock = DockStyle.Fill
            };

            this.Controls.Add(browser);
        }

        private void NHTPayment_KeyDown(object sender, KeyEventArgs e)
        {
            switch (e.KeyCode)
            {
                case Keys.Escape:
                    Close();
                    break;
            }
        }

        private void NHTPayment_FormClosing(object sender, FormClosingEventArgs e)
        {
            this.Controls.RemoveAt(0);
            //Directory.Delete(String.Format("{0}{1}UserData{2}{3}", Path.GetDirectoryName(Application.ExecutablePath), Path.DirectorySeparatorChar, Path.DirectorySeparatorChar, ProfileIdentifier), true);
        }
    }
}